package org.ix.boot.mvc.controller;

import org.ix.boot.mvc.service.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class IndexController {

    @GetMapping("/")
    public String index() {
        System.out.println("hello");
        return "hello";
    }

    // 注入数组
    @Autowired
    private Action[] actions;

    @GetMapping("/actions")
    public Integer getActionLength() {
        return actions.length;
    }

    @GetMapping("/json")
    public Map<String, Object> json() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", "xishihao");
        System.out.println("json");
        return map;
    }
}
